package com.eternal.base.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.eternal.base.R;

/**
 * Created by Administrator
 * On 2020/4/23
 * Description:
 */
public class CustomToastUtils {
    private static Toast receToast;

    public static void showCenterRoundRectToast(Context context, String content) {
        if (receToast == null) {
            receToast = new Toast(context);
            receToast.setGravity(Gravity.CENTER, 0, 0);
            View view = LayoutInflater.from(context).inflate(R.layout.layout_toast_round_rectang, null);
            TextView tvContent = view.findViewById(R.id.tv_toast_content);
            tvContent.setText(content);
            receToast.setView(view);
        } else {
            TextView tvContent = receToast.getView().findViewById(R.id.tv_toast_content);
            if (null != tvContent) {
                tvContent.setText(content);
            }
        }
        receToast.setDuration(Toast.LENGTH_SHORT);
        receToast.show();
    }
}
